
*----------------------------------------------------------------------------------------------------------	* 
* RESEARCHERS:		EARN												   									*
* PROGRAMMED BY:	Linea Hasager																			*
* DESCRIPTION:		Language training assignment and employment services.			 						*
* CREATED:			Sep. 27, 2019																		   	*
* LAST MODIFIED:	May 25, 2022														       				*
*----------------------------------------------------------------------------------------------------------	*


clear 
set more off

// Directories
global in "L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Input"
global output "L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Output"
global temp "L:\Workdata\707455\Papers\ABFHP_1999reform\Code\ReStat\Temp"


*--------------------------------------------------------------------------------------------------------	

***********************
* 1) LOAD DATA
***********************

use "${in}\Analysis_sample.dta", replace






***********************************************************************************
*	2) ESTIMATIONS
***********************************************************************************


*PARTICIPATION IN LANGUAGE TRAINING
*Dummy for ever participating within x months
foreach var in in_dkdb  {
foreach i in  12 18 24 30 36 {
rdrobust `var'_`i' day_nr,  kernel(tri) c(0) p(1)
eststo `var'_`i'e
estadd scalar alpha=e(beta_p_l)[1,1]
}
}


*PARTICIPATION IN EMPLOYMENT SUPPORT
foreach var in emplser  {
foreach i in 12 18 24 30 36 {
rdrobust `var'_`i'_d day_nr,  kernel(tri) c(0) p(1)
eststo `var'_`i'_d_e
estadd scalar alpha=e(beta_p_l)[1,1]
}
}



*HOURS ASSIGNED LANGAUGE TRAINING AND EMPLOYMENT SUPPORT, CONDITIONAL ON PARTICIPATION
foreach var in hours_assigned hours_emplser {
foreach i in  12 18 24 30 36 {
rdrobust `var'_`i' day_nr if amfo_`i'_d==1 & amfo_dkdb_`i'==1, kernel(tri) c(0) p(1) 
eststo `var'_`i'_e
estadd scalar alpha=e(beta_p_l)[1,1]
}
}




**********************************************************************************************************
*	3) TABLE FOR TIMING OF TREATMENT, COMBINING AMFORA (EMPLOYMENT SERVICES) AND DKDB (LANGUAGE TRAINING)
**********************************************************************************************************


esttab in_dkdb_12e in_dkdb_18e in_dkdb_24e in_dkdb_30e in_dkdb_36e using "${output}\oa_table1.tex", replace se(%15.3fc) b(%15.3fc) nolabel nomtitle varlabel (RD_Estimate "RD Estimate") noobs nolines nonum nonotes nogaps postfoot("") prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}\begin{tabular}{l*{8}{cc}}\toprule & 1 Year & 1.5 Years & 2 Years & 2.5 Years & 3 Years \\  & (1) & (2) & (3) & (4) & (5) \\ \midrule") star(* 0.10 ** 0.05 *** 0.01)  posthead("& \multicolumn{5}{c}{\emph{Panel a. Share Ever Participating in Language Training}} \\")  stats(alpha, fmt(%15.3fc) label("Mean for Untreated at Cutoff")) 

esttab  emplser_12_d_e emplser_18_d_e emplser_24_d_e emplser_30_d_e emplser_36_d_e using "${output}\oa_table1.tex", append se(%15.3fc) b(%15.3fc) label nomtitle varlabel (RD_Estimate "RD Estimate") stats(alpha N, fmt(%15.3fc %5.0fc) label("Mean for Untreated at Cutoff" "N")) nolines nonum nonotes nogaps posthead("& \multicolumn{5}{c}{\emph{Panel b. Share Ever Participating in Employment Support}} \\") prehead("") postfoot("") star(* 0.10 ** 0.05 *** 0.01)


esttab  hours_assigned_12_e hours_assigned_18_e hours_assigned_24_e hours_assigned_30_e hours_assigned_36_e using "${output}\oa_table1.tex", append se(%15.3fc) b(%15.3fc) label nomtitle varlabel (RD_Estimate "RD Estimate") noobs nolines nonum nonotes nogaps  posthead("& & & & & \\ & \multicolumn{5}{c}{\emph{Panel c. Cumulative Hours of Language Training}} \\") prehead("") postfoot("") star(* 0.10 ** 0.05 *** 0.01) stats(alpha, fmt(%15.3fc) label("Mean for Untreated at Cutoff")) 

esttab  hours_emplser_12_e hours_emplser_18_e hours_emplser_24_e hours_emplser_30_e hours_emplser_36_e using "${output}\oa_table1.tex", append se(%15.3fc) b(%15.3fc) label nomtitle varlabel (RD_Estimate "RD Estimate") stats(alpha N, fmt(%15.3fc %5.0fc) label("Mean for Untreated at Cutoff" "N")) nolines nonum nonotes nogaps posthead("& & & & & \\ & \multicolumn{5}{c}{\emph{Panel d. Cumulative Hours of Employment Support}} \\") prehead("") postfoot("\bottomrule\end{tabular}}") star(* 0.10 ** 0.05 *** 0.01)



